/*
* Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved.
* Description: none
* Author: s00452708
* Create: 2018-08-01
* Notes: none
* History: 2018-08-01 s00452708 create
*/

#ifndef TYPES_H
#define TYPES_H
#include <stdio.h>
#include <sys/cdefs.h>
#include <string.h>
#if CMSCBB_WITHOUT_SECUREC == 0
#include "securec.h"
#endif

#ifndef dma_haddr_t
typedef unsigned long long dma_haddr_t;
#endif

#ifndef s8
typedef signed char s8; /* signed char */
#endif

#ifndef u8
typedef unsigned char u8; /* unsigned char */
#endif

#ifndef s16
typedef signed short s16; /* sigened short */
#endif

#ifndef u16
typedef unsigned short u16; /* unsigned short */
#endif

#ifndef s32
typedef signed int s32; /* signed int */
#endif

#ifndef u32
typedef unsigned int u32; /* unsigned int */
#endif

#ifndef s64
typedef signed long long s64; /* signed long long */
#endif

#ifndef u64
typedef unsigned long long u64; /* unsigned long long */
#endif

#ifndef BITS_PER_LONG
#define BITS_PER_LONG 32
#endif

#ifndef dma_addr_t
typedef u32 dma_addr_t; /* Not used */
#endif

#ifndef phys_addr_t
typedef unsigned long phys_addr_t; /* Not used */
#endif

#ifndef phys_size_t
typedef unsigned long phys_size_t; /* Not used */
#endif

#ifndef size_t
typedef __SIZE_TYPE__  size_t; /* Used to indicate sizes */
#endif

#ifndef ssize_t
typedef __ssize_t ssize_t; /* size with sign */
#endif

#ifndef UINTPTR
typedef unsigned int UINTPTR; /* Commonly used */
#endif

#ifndef INTPTR
typedef signed int INTPTR; /* Commonly used */
#endif

#ifndef loff_t
typedef __loff_t loff_t; /* Commonly used */
#endif

#ifndef u_char
typedef unsigned char u_char; /* Commonly used */
#endif

#define OS_NULL_BYTE  ((u8)0xff)            /* Not used */
#define OS_NULL_SHORT ((u16)0xffff)         /* Not used */
#define OS_NULL_INT   ((u32)0xffffffff)     /* Not used */
#define OS_SUCCESS    (0)                   /* Not used */
#define OS_FAIL       (1)                   /* Not used */
#define OS_ERROR      (-1)                  /* Not used */
#define OS_INVALID    (-1)                  /* Not used */

#ifndef VOID
#define VOID void           /* Commonly used */
#endif

#ifndef FALSE
#define FALSE ((bool)0)     /* Commonly used */
#endif

#ifndef TRUE
#define TRUE ((bool)1)      /* Commonly used */
#endif

#ifndef NULL
#define NULL ((VOID *)0)    /* Commonly used */
#endif

#ifdef YES
#undef YES
#endif
#define YES (1)             /* Commonly used */

#ifdef NO
#undef NO
#endif
#define NO (0)              /* Commonly used */

#ifndef IN
#define IN                  /* Commonly used */
#endif

#ifndef OUT
#define OUT                 /* Commonly used */
#endif

#ifndef INOUT
#define INOUT               /* Commonly used */
#endif

#ifndef bool
typedef unsigned int bool;  /* Commonly used */
#endif

enum {
    false = 0,        /* Commonly used */
    true = 0xffffffff /* Commonly used, for secure, defined as 0xffffffff */
};

#ifndef ALIGN
#define ALIGN(uwAddr, uwBoundary) (((uwAddr) + (uwBoundary)-1) & ~((uwBoundary)-1)) /* Commonly used */
#endif
#ifndef TRUNCATE
#define TRUNCATE(uwAddr, uwSize) ((uwAddr) & ~((uwSize)-1)) /* Commonly used */
#endif

static inline u32 __hrd_raw_readl(const volatile void *addr) /* Commonly used */
{
    return *(u32 *)addr;
}

static inline void __hrd_raw_writel(u32 val, volatile void *addr) /* Commonly used */
{
    (*(volatile u32 *)(addr)) = val;
}

#define HRD_READ_WORD(addr)         ({ unsigned int __v = __hrd_raw_readl(addr); __v; })
#define HRD_WRITE_WORD(value, addr) __hrd_raw_writel(value, addr)

#define OS_READL  HRD_READ_WORD  /* Commonly used */
#define OS_WRITEL HRD_WRITE_WORD /* Commonly used */


#endif
